<?php
use yii\bootstrap\Nav;
use mdm\admin\components\MenuHelper;
use ua_backend\components\Menu;
?>

<aside class="main-sidebar">

    <section class="sidebar">

        <div class="space20"></div>

        <?php
        $callback = function($menu){
            $data = json_decode($menu['data'], true);

            $items = $menu['children'];
            $return = [
                'label' => Yii::t('menu', $menu['name']),
                'url' => [$menu['route']],
            ];


            if ($data) {
                //visible
                isset($data['visible']) && $return['visible'] = $data['visible'];
                //icon
                isset($data['icon']) && $data['icon'] && $return['icon'] = $data['icon'];
                //other attribute e.g. class...
                $return['options'] = $data;
            }

            $items && $return['items'] = $items;

            return $return;
        };


        echo Menu::widget([
//            'options' => ['class' => 'sidebar-menu tree', 'data-widget'=> 'tree'],
            'items' => MenuHelper::getAssignedMenu(Yii::$app->user->id, null, $callback, true),
        ]); ?>


    </section>

</aside>
